package main

import (
	"context"
	"fmt"
	"github.com/go-redis/redis/v8"
	"go.uber.org/zap"
)

func main() {
	var ctx = context.Background()
	redisObj := redis.NewClient(&redis.Options{
		Addr:     fmt.Sprintf("%s:%d", "r-m5en6w7ln6xh8bpird.redis.rds.aliyuncs.com", 6379),
		Password: "qwer123$", // no password set
		DB:       1,          // use default DB
	})

	_, err := redisObj.Ping(ctx).Result()
	if err != nil {
		fmt.Println("[InitRedisConn] 连接 【redis连接失败】")
		zap.S().Fatal("[InitRedisConn] 连接 【redis连接失败】")
	}

	redisObj.Set(ctx, "test", "test1", 0)
	fmt.Println(redisObj.Get(ctx, "test").Result())

}
